<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('审核本级回复未处理T')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            工单编号：<input type="text" name="workFormNO"/>
                        </li>
                        <li>
                            派发单位：<input type="text" name="sdeptName"/>
                        </li>
                        <li>
                            审核人员：<input type="text" name="opUserName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm " id="toolbar" role="group">
            <a class="btn btn-success multiple disabled" onclick="audit()">
                <i class="fa"></i> 审核
            </a>&nbsp;
            <a class="btn btn-success" id="getBackWaitData" onclick="getBackWaitList()">
                <i class="fa fa-plus"></i> 获取
            </a>&nbsp;&nbsp;
            <label class="control-label">总共还有<span class="spRed" th:value="${num}"
                                                       id="remainCount">[[${num}]]</span>条数据未获取</label>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/common/js/common.js}"></script>
<script th:inline="javascript">
    var count = [[${num}]] //未获取的数量
    var cmnTab = ctx + "gaoxin/system/cmnTab";
    var prefix = ctx + "gaoxin/system/mTelWF";

    $(function () {
        var options = {
            url: prefix + "/cmnFile/getMuReplyChkJson",
            sortName: "bkLimit",
            sortOrder: "asc",
            uniqueId: "myPkVal",
            modalName: "审核本级回复T",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            rowStyle: rowStyle,
            columns: [{
                checkbox: true
            },
                {
                    field: '', title: '序号', align: "center", width: 40, formatter: function (value, row, index) {
                        return serialNumber(value, row, index);
                    }
                },
                {field: 'myPkVal', title: 'pkId', hidden: true, visible: false},
                {field: 'wfId', title: 'wfId', hidden: true, visible: false},
                {field: 'fmDept', title: 'fmDept', hidden: true, visible: false},
                {field: 'OriLevel', title: 'OriLevel', hidden: true, visible: false},
                {field: 'sbDept', title: 'sbDept', hidden: true, visible: false},
                {field: 'myTwfNO', title: '工单编号', align: 'center', sortable: true},
                {field: 'myTwfTopic', title: '工单主题', align: 'center', sortable: true},
                {field: 'SeqName', title: '交办次序', align: 'center'},
                {field: 'SortName', title: '性质', align: 'center', sortable: true},
                {field: 'DealName', title: '办理方式', align: 'center', hidden: true},
                {field: 'bkLimit', title: '办理期限', align: 'center', sortable: true, width: 80},
                {field: 'SDeptName', title: '来自', align: 'center', hidden: true},
                {field: 'SBDeptName', title: '办理单位', align: 'center', width: 80},
                {field: 'bkDate', title: '回复日期', align: 'center'},
                {
                    field: 'chgBack',
                    title: '审查结果',
                    align: 'center',
                    sortable: true,
                    width: 80,
                    formatter: function (value, row, index) {
                        return fmtSBBackCheck(value, row, index);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="audit(' + row.WfId + ',' + row.myPkVal + ')"><i class="fa"></i>审核</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
        //未获取数量小于等于0
        if (count <= 0) {
            $('#getBackWaitData').addClass('disabled');
        }
    });

    //审核？单选（派单详情+审核回复）：多选（批量审核）
    function audit(wfId, sendId) {
        let row = $("#bootstrap-table").bootstrapTable('getSelections');
        if (row.length > 1) {//批量审核
            var ids = "";
            $.each(row, function (index, value) {
                ids += row[index].myPkVal + ",";
            })
            ids = ids.substr(0, ids.length - 1);
            var url = prefix + "/cmnFile/dlBatchChkReply?ids=" + ids;
            var title = '批量审核';
            var width = "500px";
            var height = "500px";
            var options = {
                url: url,
                title: title,
                width: width,
                height: height,
                btnArr: []
            }
            winDialog(options);
        } else {//审核页面
            if (!(wfId && sendId)) {
                var wfId = row[0].WfId;
                var sendId = row[0].myPkVal;
            }
            var url = cmnTab + "/twfCChkS/" + sendId;
            parent.$.modal.openTab('审核回复', url);
        }
    }

    function getBackWaitList() {
        var url = prefix + "/cmnFile/countAWaitPeerReply";
        parent.$.modal.open('获取审核本级回复未处理工单T', url, 400, 200);
    }

</script>
</body>
</html>